home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / xml / WrapOutputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  1.6 KB  |  75 lines

  1. package com.extensibility.xml;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.OutputStream;
  8. import java.net.HttpURLConnection;
  9.  
  10. class WrapOutputStream extends OutputStream {
  11.    private OutputStream realStream;
  12.    private HttpURLConnection urlc;
  13.  
  14.    public WrapOutputStream(OutputStream var1, HttpURLConnection var2) {
  15.       this.realStream = var1;
  16.       this.urlc = var2;
  17.    }
  18.  
  19.    public void flush() throws IOException {
  20.       if (this.realStream != null) {
  21.          this.realStream.flush();
  22.       }
  23.  
  24.    }
  25.  
  26.    public void close() throws IOException {
  27.       if (this.realStream != null) {
  28.          this.realStream.close();
  29.       }
  30.  
  31.       if (this.urlc != null) {
  32.          InputStream var1;
  33.          try {
  34.             var1 = this.urlc.getInputStream();
  35.          } catch (IOException var6) {
  36.             this.urlc.disconnect();
  37.             throw new IOException(((Throwable)var6).getMessage());
  38.          }
  39.  
  40.          BufferedReader var3 = new BufferedReader(new InputStreamReader(var1));
  41.  
  42.          String var4;
  43.          for(String var5 = ""; (var4 = var3.readLine()) != null; var5 = String.valueOf(var5).concat(String.valueOf(var4))) {
  44.          }
  45.  
  46.          var3.close();
  47.          this.urlc.disconnect();
  48.          this.urlc = null;
  49.          System.gc();
  50.       }
  51.  
  52.    }
  53.  
  54.    public void write(byte[] var1) throws IOException {
  55.       if (this.realStream != null) {
  56.          this.realStream.write(var1);
  57.       }
  58.  
  59.    }
  60.  
  61.    public void write(byte[] var1, int var2, int var3) throws IOException {
  62.       if (this.realStream != null) {
  63.          this.realStream.write(var1, var2, var3);
  64.       }
  65.  
  66.    }
  67.  
  68.    public void write(int var1) throws IOException {
  69.       if (this.realStream != null) {
  70.          this.realStream.write(var1);
  71.       }
  72.  
  73.    }
  74. }
  75.